<!-- templates/edit_agricultural_product.html -->
{% extends 'base.html' %}
{% load static %}
{% block content %}

<div class="container py-4">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card shadow-sm">
                <div class="card-header bg-primary text-white">
                    <h5 class="mb-0">✏️ 编辑农产品信息</h5>
                </div>
                <div class="card-body">
                    <form method="post" enctype="multipart/form-data">
                        {% csrf_token %}
                                               <!-- 原材料来源 -->
                        <div class="mb-3">
                            <label for="{{ form.product_name.id_for_label }}" class="form-label">商品名称</label>
                            {{ form.product_name }}
                        </div>

                        <!-- 原材料来源 -->
                        <div class="mb-3">
                            <label for="{{ form.raw_material_source.id_for_label }}" class="form-label">原材料来源</label>
                            {{ form.raw_material_source }}
                        </div>

                        <!-- 生产过程 -->
                        <div class="mb-3">
                            <label for="{{ form.production_process.id_for_label }}" class="form-label">生产过程</label>
                            {{ form.production_process }}
                        </div>

                        <!-- 检验批次 -->
                        <div class="mb-3">
                            <label for="{{ form.inspection_batch.id_for_label }}" class="form-label">检验批次</label>
                            {{ form.inspection_batch }}
                        </div>

                        <!-- 物流流转 -->
                        <div class="mb-3">
                            <label for="{{ form.logistics_flow.id_for_label }}" class="form-label">物流流转</label>
                            {{ form.logistics_flow }}
                        </div>

                        <!-- 防伪鉴证 -->
                        <div class="mb-3">
                            <label for="{{ form.anti_counterfeiting_certification.id_for_label }}" class="form-label">防伪鉴证</label>
                            {{ form.anti_counterfeiting_certification }}
                        </div>

                        <!-- 价格 -->
                        <div class="mb-3">
                            <label for="{{ form.price.id_for_label }}" class="form-label">价格</label>
                            {{ form.price }}
                        </div>

                        <!-- 产品图片 -->
                        <div class="mb-3">
                            <label for="{{ form.product_image.id_for_label }}" class="form-label">产品图片</label>
                            {{ form.product_image }}
                            {% if product.product_image %}
                                <div class="mt-2">
                                    <img src="{{ product.product_image.url }}" alt="当前图片" style="max-height: 150px;">
                                </div>
                            {% endif %}
                        </div>

                        <!-- 提交按钮 -->
                        <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                            <button type="submit" class="btn btn-success">保存更改</button>
                            <a href="{% url 'agricultural_product_list' %}" class="btn btn-secondary">取消</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

{% endblock %}
